import unittest
import ddt
import requests
from common.excel_read import ExcelUtil
excel = ExcelUtil(r'..\excel_data\changepass.xls', 'Sheet1')


@ddt.ddt
class DataTest2(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.sess = requests.session()
        re = cls.sess.post(url='http://192.168.2.180:8080/WoniuBoss2.5/log/userLogin',
                           data={"userName": "WNCD002", "userPass": "123456", "checkcode": "0000"})
        print(re.text)

    @classmethod
    def tearDownClass(cls):
        cls.sess.close()

    @ddt.data(*excel.next())
    def testChangePass(self, data):
        # print(data)
        result = self.sess.post(url=data['URL'], data=eval(data['parameter']))
        print(data['URL'])
        print(result.text)
        assert data['result'] in result.text


